package com.atguigu.spring5.collection.test;

import com.atguigu.spring5.collection.Book;
import com.atguigu.spring5.collection.Course;
import com.atguigu.spring5.collection.Stu;
import com.atguigu.spring5.collection.autowire.Emp;
import com.atguigu.spring5.collection.bean.Orders;
import com.atguigu.spring5.collection.factorybean.Mybean;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author durant
 * @create 2021-10-30 10:22
 */
public class test1 {
    @Test
    public void testCollection(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean1.xml");
        Stu stu = context.getBean("stu", Stu.class);
        stu.test();
    }
    @Test
    public void testCollection2(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean2.xml");
        Book book = context.getBean("book", Book.class);
        book.add();
    }
    @Test
    public void testCollection3(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean3.xml");
        Course mybean = context.getBean("mybean", Course.class);

    }
    @Test
    public void testCollection4(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean4.xml");
        Orders order = context.getBean("orders", Orders.class);
        System.out.println("第四步获取到对象");
        ((ClassPathXmlApplicationContext) context).close();
    }
    @Test
    public void autowiretest(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean5.xml");
        Emp emp = context.getBean("emp", Emp.class);
        System.out.println(emp);
        emp.test();
    }
}
